home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 602 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4h4jl4$2iq@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 29 Feb 1996 16:18:44 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 01 Mar 96 13:43:43 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Return-Path: <daemon@meeker.UCAR.EDU>
  8. Newsgroups: comp.std.c++
  9. Subject: Re: Namespaces within class definition???
  10. Organization: Sun Microsystems Inc.
  11. References: <4h2mlp$s3c@nnrp1.news.primenet.com>
  12. Reply-To: clamage@Eng.Sun.COM
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMTcDzuEDnX0m9pzZAQGvVQGAmdcGtKbRK1dVHQUf1UeTAG9tEUkDEz17
  15.     eS9ehkm3G4ETg2aQKhHxwWD2j4lwEpcE
  16.     =CLJG
  17.  
  18. In article s3c@nnrp1.news.primenet.com, kj7bg@primenet.com (Bob White) writes:
  19. >...  I tried the following and it seems to work:
  20. >
  21. >typedef    std::string XyzString;
  22. >class xyz : public XyzString { }
  23. >
  24. >So I will use it until Borland and Microsoft allow me the more 
  25. >straight forward way.  Also, I am using the "string" class as defined by one 
  26. >version of the C++ standard which was put in the "std" namespace.  I thought
  27. >this was what the current standard required!
  28.  
  29. Yes. The draft standard defines a string class called "string", and
  30. all library elements are in the "std" namespace. You have basically
  31. three ways to access names in the standard library:
  32. 1. Explicit qualification:
  33.     std::string MyString;
  34. 2. A using-declaration:
  35.     using std::string;
  36.     string MyString;
  37. 3. A using-directive:
  38.     using namespace std;
  39.     string MyString;
  40.  
  41. The using-declaration (#2) places the specified name in the current scope
  42. having its original declaration.
  43.  
  44. The using-directive (#3) makes all names from the namespace visible from
  45. the current scope, which is subtly different from placing those names IN
  46. the current scope. (And subtly different from placing them in a notional
  47. surrounding scope.) See Stroustrup's "Design and Evolution of C++" for
  48. more details.
  49.  
  50. Your typedef is a variation of #1.
  51.  
  52. ---
  53. Steve Clamage, stephen.clamage@eng.sun.com
  54. ---
  55. [ To submit articles: try just posting with your news-reader.
  56.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  57.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  58.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  59.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  60. ]
  61.